package com.neuedu.javase.collection;

import java.util.*;

/***
 * 项目名称:  MyJavaSE 
 * 包：  com.neuedu.javase.collection 
 * date:   2025/11/5   11:49  
 * 描述:  \
 *  @author : 张金山
 *  作者博客:   https://blog.fulfill.com.cn
 */
public class NormalException {


    public static void main(String[] args) {

        List list = new ArrayList();



        //ok
        // list.add("张三");
        // list.add(Integer.valueOf(1000));
        // Integer num = (Integer) list.get(1);

        //错误
        /**
         * Exception in thread "main" java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')
         * 	at com.neuedu.javase.collection.NormalException.main(NormalException.java:31)
         */
        // list.add("张三");
        // Integer num = (Integer) list.get(0);


    //     UnsupportedOperationException
        /**
         * public void add(int index, E element) {
         *         throw new UnsupportedOperationException();
         *     }
         *
         *
         *  java.util.Arrays$ArrayList   没有  add功能
         *Exception in thread "main" java.lang.UnsupportedOperationException
         * 	at java.base/java.util.AbstractList.add(AbstractList.java:153)
         * 	at java.base/java.util.AbstractList.add(AbstractList.java:111)
         * 	at com.neuedu.javase.collection.NormalException.main(NormalException.java:44)
         *
         */
        // List list2 = Arrays.asList("张三","李四");
        //
        // //java.util.Arrays$ArrayList      java.util.ArrayList
        // System.out.println("list2.getClass() = " + list2.getClass());
        //
        // list2.add("王五");




        //NoSuchElementException
        /**
         * Exception in thread "main" java.util.NoSuchElementException
         * 	at java.base/java.util.LinkedList.getFirst(LinkedList.java:248)
         * 	at com.neuedu.javase.collection.NormalException.main(NormalException.java:65)
         */
        // LinkedList linkedList = new LinkedList();
        // linkedList.getFirst();



        //ConcurrentModificationException
        // List names  = new ArrayList(Arrays.asList("张三","李四"));
        // for (Iterator it = names.iterator(); it.hasNext();  ) {
        //
        //     names.remove(it.next());
        // }

    }
}
